<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="<%=basePath%>">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta content="telephone=no,email=no" name="format-detection">
    <meta name="wap-font-scale" content="no">
    <title>首页</title>
    <!-- 公用样式css -->
    <link href="css/base.css" rel="stylesheet" type="text/css" />
    <!--banner-->
    <link href="css/weui.min.css" rel="stylesheet" type="text/css" />
    <link href="css/jquery-weui.min.css" rel="stylesheet" type="text/css" />
    <!--concent-->
    <link href="css/index.css" rel="stylesheet" type="text/css" />
    <!--底部样式css-->
    <link href="css/footer.css" rel="stylesheet" type="text/css" />
    <!--日期css-->
    <link href="css/date.css" rel="stylesheet" type="text/css" />

    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/slider.js"></script>
    <style>
        img{max-width:100%}
    </style>
</head>

<body>
<header class="header wor-colour8">
    <div class="header-left">首页</div>
    <a href="<%=basePath%>/member/memberCenter" class="header-right wor-colour8 word4">我的</a>
</header>
<div class="main bot44">
    <!-- 轮播图 -->
    <section class="aui-scrollView">
        <div class="m-slider" data-ydui-slider>
            <div class="slider-wrapper">
                <div class="slider-item">
                    <a href="javascript:return false;"><img src="images/bjimg1.jpg" alt=""></a>
                </div>
                <div class="slider-item">
                    <a href="javascript:return false;"><img src="images/bjimg2.jpg" alt=""></a>
                </div>
            </div>
            <div class="slider-pagination"></div>
        </div>
    </section>
<!---轮播图-->
    <!--concent-->
    <div class="frame-bord">
        <div class="or-all">
            <ul class="orientate" >
                <li style="height:auto;line-height:normal"  onclick="getCity();">
                    <p class="word1 wor-colour1">请选择城市</p>
                    <c:if test='${city eq ""|| city == null}'>
                        <p class="word5 wor-colour8" >请选择</p>
                    </c:if>
                    <c:if test='${city != ""}'>
                        <p class="word5 wor-colour8" id="cityNameP">${cityName}</p>
                    </c:if>
                </li>
                <li style="height:auto;line-height:normal" onclick="onSuccess()"><img class="location-img" src="images/icon1.png"/><p class="word1 wor-colour1">我的位置</p></li>
            </ul>
            <%--             	<div class="row orientate">
                                <p class="word1 wor-colour1">请选择城市</p>
                                <c:if test='${city eq ""|| city == null}'>
                                    <p class="word5 wor-colour8" >请选择</p>
                                </c:if>
                                <c:if test='${city != ""}'>
                                    <p class="word5 wor-colour8" id="cityNameP">${cityName}</p>
                                </c:if>
                                <div onclick="getLocalCity()" style="float:right;width:30%"><img class="location-img" src="images/icon1.png"/><p class="word1 wor-colour1">我的位置</p></div>
                            </div> --%>
        </div>
        <div class="line"></div>
        <div class="or-all">
            <div class="row select-time orientate">
                <p class="word1 wor-colour1">入离店日期</p>
                <span class="word5 wor-colour8 entertime"></span>
                <span class="word5 wor-colour8">至</span>
                <span class="word5 wor-colour8 leavetime"></span>
                <span class="word1 wor-colour1 wor-height night">共1晚</span>
            </div>
        </div>
    </div>
    <div class="mt20">
        <a href="#" class="weui-btn  weui-btn_primary order" onclick="_submit();return false;">确认下单</a>
    </div>
    <form id="submitForm" method="post">
        <input type="hidden" name="url" value="home/index">
        <input type="hidden" name="city" value="${city}" id="city">
        <input type="hidden" name="cityName" value="${cityName}" id="cityName">
        <input type="hidden" name="startDate" class="input-enter" value="${startDate}"/>
        <input type="hidden" name="endDate" class="input-leave" value="${endDate}"/>
        <input type="hidden" name="lat" id="lat" value="${lat}"/>
        <input type="hidden" name="lng" id="lng" value="${lng}"/>
        <input type="hidden" name="openId" value="${openId}">
    </form>

    <c:forEach items="${citys}" var="item">
        <input type="hidden" class="citys" city="${item.Code}" cityName="${item.AreaName}" />
    </c:forEach>
</div>

<!-- footer -->
<footer class="footer">
    <!-- <div class="footer-img"><img class="img-bottom" src="images/icon37.png" />&nbsp;</div> -->
</footer>
<!-- footer -->

</body>
<!-- jquery引入 -->
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<!-- weui引入-->
<script type="text/javascript" src="js/jquery/weui.js"></script>
<!-- swiper引入-->
<script type="text/javascript" src="js/jquery/swiper.js"></script>
<!-- 界面对应js -->
<script type="text/javascript" src="js/jquery/index.js"></script>
<!-- 界面对应js -->
<script type="text/javascript" src="js/jsaes.js"></script>
<!-- 日期对应js -->
<script type="text/javascript" src="js/date.js"></script>
<%--<link href="js/broadcast/broadcast.css" rel="stylesheet" type="text/css" />--%>
<link href="css/banner-4-2.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/broadcast/slider.js"></script>
<script type="text/javascript" src="js/broadcast/tab.js"></script>
<script type="text/javascript" src="js/artDialog/artDialog.source.js?skin=simple"></script>
<script type="text/javascript" src="js/artDialog/plugins/iframeTools.source.js"></script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<script type="text/javascript">
    $('.select-time').hotelDate();
    function _submit(){
        if($("#lat").val()==null||$("#lat").val()==""){
            wx.getLocation({
                type: 'wgs84',
                complete:function(argv){
                    if(argv.errMsg=="getLocation:ok"){
                        $("#lat").val(argv.latitude);
                        $("#lng").val(argv.longitude);
                        _submit_data();
                    }else{
                        _submit_data();
                    }
                },
                cancel: function (res) {
                    _submit_data();
                }
            });
        }else{
            _submit_data();
        }
    }

    function _submit_data(){
        var city=$("#city").val();
        if(city==null||city==""){
            art.dialog.tips('请选择地址');
        }else{
            $("#submitForm").attr("action","home/hotelList").submit();
        }

    }

    function getCity(){
        $("#submitForm").attr("action","home/gardenCity").submit();
    }

    $(document).ready(function(){
        wx.config({
            debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
            appId: '${wxMap.appId}', // 必填，公众号的唯一标识
            timestamp: '${wxMap.timestamp}' , // 必填，生成签名的时间戳
            nonceStr: '${wxMap.nonceStr}', // 必填，生成签名的随机串
            signature: '${wxMap.signature}',// 必填，签名
            jsApiList: [
                'getLocation' //获取地理位置接口
            ]
        });

        wx.ready(function(){
            wx.getLocation({
                type: 'wgs84',
                complete:function(argv){
                    if(argv.errMsg=="getLocation:ok"){
                        $("#lat").val(argv.latitude);
                        $("#lng").val(argv.longitude);
                    }
                }
            });
        });
    });
    //成功时
    function onSuccess(){
        if($("#lat").val()==null||$("#lat").val()==""){
            wx.getLocation({
                type: 'wgs84',
                complete:function(argv){
                    if(argv.errMsg=="getLocation:ok"){
                        $("#lat").val(argv.latitude);
                        $("#lng").val(argv.longitude);
                        onSuccess();
                    }else{
                        art.dialog.tips("暂未获取到位置信息");
                    }
                },
                cancel: function (res) {
                    art.dialog.tips("用户拒绝授权获取地理位置");
                }
            });
        }else{
            var data={
                location:$("#lat").val()+","+$("#lng").val(),
                key:"EOIBZ-7MGE3-UD43R-YOZMB-37FYT-RHBGQ",
                get_poi:0,
                output:"jsonp"
            }
            var url="http://apis.map.qq.com/ws/geocoder/v1/?";
            $.ajax({
                type:"get",
                dataType:'jsonp',
                data:data,
                jsonp:"callback",
                jsonpCallback:"QQmap",
                url:url,
                success:function(json){
                    if(json.status==0){
                        var city=json.result.address_component.city;
                        var NOTcity=true;
                        $(".citys").each(function(){
                            if($(this).attr("cityName")==city){
                                $("#cityName").val(city);
                                $("#city").val($(this).attr("city"));
                                $("#cityNameP").html($(this).attr("cityName"));
                                NOTcity=false;
                                return;
                            }
                        })
                        if(NOTcity){
                            art.dialog.tips("未定位到开通城市")
                        }
                    }else{
                        art.dialog.tips("定位城市失败");
                    }
                },
                error : function(err){}
            });
        }
    }
</script>
</html>